// 关于文章的接口
import http from '@/utils/request'
export const reqGetCate = () => http({
  method: 'GET',
  url: '/my/cate/list'
})

// 新增文章分类
export const reqAddCate = data => http({
  method: 'POST',
  url: '/my/cate/add',
  data
})

// 删除文章
export const reqDeleteCate = id => http({
  method: 'DELETE',
  url: '/my/cate/del',
  params: { id: id }
})

// 根据id查询文章分类详情
export const reqGetCateInfoById = id => {
  return http({
    method: 'get',
    url: '/my/cate/info',
    params: { id: id }
  })
}

// 根据 id 更新文章分类数据
export const reqUpdataArticle = data => {
  return http({
    method: 'put',
    url: '/my/cate/info',
    data
  })
}

// 查询文章列表

export const reqGetArtList = obj => http({
  method: 'get',
  url: '/my/article/list',
  params: obj
})
// reqGetArtList({ pagenum: 1, pagesize: 2, cate_id: 1, state: 'xxx' })

/*
根据 id 获取文章详情
文章的 id，注意：这是一个 URL 查询参数
*/
export const reqGetArtInfo = id => {
  return http({
    method: 'get',
    url: '/my/article/info',
    params: {
      id
    }
  })
}

/*
  根据id删除文章
  参数id: 要删除的文章 id，注意：这是一个 URL 查询参数
*/
export const reqDelArticleById = id => {
  return http({
    method: 'delete',
    url: '/my/article/info',
    params: {
      id
    }
  })
}
// 发布文章的接口
export const reqPublishArticle = (data) => {
  return http({
    method: 'post',
    url: '/my/article/add',
    data
  })
}
